import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

const OUTFRANGE = -500;

@ccclass('bullet')
export class Bullet extends Component {

    @property
    public bulletSpeed = 3
 

    start() {

    }

    update(deltaTime: number) {
        const postion = this.node.getPosition()
        const newZ = this.node.getPosition().z - this.bulletSpeed
        this.node.setPosition(postion.x, postion.y, newZ);

        if(newZ < OUTFRANGE){
            this.node.destroy()
        }
    }
}


